package com.yhp.dao.iml;

import com.yhp.bean.Grade;
import com.yhp.dao.GradeDao;
import com.yhp.util.DbUtils;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GradeDaoImpl extends DbUtils implements GradeDao {

    @Override
    public List<Grade> getGrade() {
        List list = new ArrayList();
        try {
            String sql = "select * from grade";
            resultSet = query(sql, null);
            while (resultSet.next()){
                Grade grade = new Grade();
                grade.setGradeid(resultSet.getInt("gradeid"));
                grade.setGradename(resultSet.getString("gradename"));
                list.add(grade);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeAll();
        }
        return list;
    }
}
